package com.myapp.ruyixing.http;

import org.json.JSONObject;

import com.myapp.ruyixing.model.UserInfo;

public class UserInfoParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		if (getErrno(jsonObject) != NO_ERROR) {
			return null;
		}

		UserInfo userInfo = new UserInfo();

		ModelParser.parseModel(userInfo, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		userInfo.username = data.optString("username");
		userInfo.avatar = data.optString("avatar");
		userInfo.livecity = data.optString("livecity");
		userInfo.cityid = data.optString("cityid");
		userInfo.sex = data.optString("sex");
		userInfo.photo = data.optInt("photo", 0);
		userInfo.status = data.optInt("status", 0);
		userInfo.review = data.optInt("review", 0);
		userInfo.signin = data.optInt("signin", 0);
		return userInfo;
	}
}
